{include file="public/header" /}
<body>

<div class="x-body">
    <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>

    <form  class="layui-form">
        <div class="layui-form-item">
            <label for="" class="layui-form-label" style="width: 120px;">选择图纸明细编号</label>
            <input type="hidden" value="{$drawing_detail_id}" id="drawing_detail_id">
            <div class="layui-input-inline">
                <select name="copy" lay-verify="required" lay-search="" id="copy">
                    <option value="">请输入关键字...</option>
                    <optgroup label="明细编号">
                        {volist name="$blueprintAllInfo" id="blueprintInfoList"}
                        <option value="{$blueprintInfoList.drawing_detail_id}">{$blueprintInfoList.drawing_detail_id}</option>
                        {/volist}
                    </optgroup>
                </select>
            </div>
        </div>
        <div class="layui-form-item"  style="width: 600px;margin-top:100px; ">
            <label class="layui-form-label"></label>
            <input type="button" value="复制"  class="layui-btn"  onclick="buttonCope()">
        </div>
    </form>
</div>
<script>
    function buttonCope() {
        var copy = $("#copy").val();
        if(copy == ''){
            layer.msg('请选择图纸编号');
            return ;
        }
        var drawing_detail_id =  $("#drawing_detail_id").val();
        layer.confirm('确定要将'+copy+'图纸下列的所有工艺复制到' + drawing_detail_id +'图纸下面吗？',function(index){
            var url = "{:url('/index/Blueprint/exeCopysProcess')}";
            var postData ={"copy":copy,"drawing_detail_id":drawing_detail_id};
            $.post(url,postData,function (result) {
                if(result.code === 1000 ){
                    layer.alert(result.msg, {icon: 5});
                    return;
                }
                if(result.code === 1 ){
                    layer.alert("复制成功", {icon: 6},function () {
                        window.parent.location.reload();  //刷新父级页面
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                    });
                }else {
                    layer.alert("复制失败", {icon: 5});
                }
            },"json");
        });
    }
</script>
</body>

</html>